package com.yanqu.road.web.controller.game;

import com.yanqu.road.entity.web.GmCommandParam;
import com.yanqu.road.server.manger.WhiteIpMgr;
import com.yanqu.road.web.util.IpAddressHelper;
import com.yanqu.road.webservice.invoke.GameWebServiceInvoke;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;

@RestController
public class ExecuteAdminCommand {
    @RequestMapping("/execCommand")
    public Object execCommand(@RequestBody GmCommandParam param, HttpServletRequest request) {
        //校验访问IP
        String ip = IpAddressHelper.getIpAddr(request);
        if(!WhiteIpMgr.isConsoleWhiteIp(ip)){
            return -10;            //访问IP非法
        }
        int ret = GameWebServiceInvoke.executeAdminCommand(param.getUserId(), param.getCommands());
        return 1;
    }
}
